/**
 * ...
 * @author 
 */

package ;
import bloom.remoting.RemotingQueue;

class BackendProxy extends haxe.remoting.AsyncProxy<BackendAPI> {}


class Flash 
{
    public static inline var URL = "php/index.php";
    
    public static function main () 
    {
        
        var cnx = haxe.remoting.HttpAsyncConnection.urlConnect(URL);
        
        // Error Handler
        cnx.setErrorHandler(function (e) { trace("onError: " + Std.string(e)); } );
        
        // BackendAPI Proxy
        var proxy = new BackendProxy(cnx.backend);
                
        
        // callbacks
        var cb1 = function (s) trace("Queue1: " + Std.string(s));
        var cb2 = function (s) trace("Queue2: " + Std.string(s));
        var cb3 = function (s) trace("Queue3: " + Std.string(s));
        var cb4 = function (s) trace("Queue4: " + Std.string(s));
        var cb5 = function (s) trace("Queue5: " + Std.string(s));
        
        // Remoting Queue
        
        var queue = new RemotingQueue();
        
        
        queue.addVoid0( proxy.doAnything ); // returns Void, no callback handler 

        queue.add0( proxy.getString, cb1 );
        queue.add0( proxy.getObj, cb2 );
        queue.add1( proxy.hello, "amore", cb3 );
        queue.add0( proxy.getDBResult, cb4 );
        queue.add3( proxy.make, "Piet", 1, 18, cb5 );
        
        
    }
}